home *** CD-ROM | disk | FTP | other *** search
/ Aminet 19 / Aminet 19 (1997)(GTI - Schatztruhe)[!][Jun 1997].iso / Aminet / dev / mui / MUIPlusPlus.lha / Source / MainHeader / List.public < prev    next >
Encoding:
Text File  |  1997-03-13  |  1.2 KB  |  59 lines

  1. // By overloading the [] operator you can treat lists like arrays
  2.  
  3. APTR operator [] (LONG pos)
  4. {
  5.     APTR entry;
  6.     DoMethod (MUIM_List_GetEntry, pos, &entry);
  7.     return entry;
  8. }
  9.  
  10. // This method is a convienient alternative to the Entries attribute
  11.  
  12. LONG Length (void) const
  13. {
  14.     return (LONG)GetAttr (MUIA_List_Entries);
  15. }
  16.  
  17. // This method can be used to retrieve the number of selected entries
  18. // in a list
  19.  
  20. ULONG NumSelected (void)
  21. {
  22.     ULONG numSelected;
  23.     DoMethod (MUIM_List_Select, MUIV_List_Select_All, MUIV_List_Select_Ask, &numSelected);
  24.     return numSelected;
  25. }
  26.  
  27. // These methods can be used as shortcuts for inserting objects into lists
  28.  
  29. void AddHead (APTR entry)
  30. {
  31.     DoMethod (MUIM_List_InsertSingle, entry, MUIV_List_Insert_Top);
  32. }
  33.  
  34. void AddTail (APTR entry)
  35. {
  36.     DoMethod (MUIM_List_InsertSingle, entry, MUIV_List_Insert_Bottom);
  37. }
  38.  
  39. void InsertTop (APTR entry)
  40. {
  41.     DoMethod (MUIM_List_InsertSingle, entry, MUIV_List_Insert_Top);
  42. }
  43.  
  44. void InsertBottom (APTR entry)
  45. {
  46.     DoMethod (MUIM_List_InsertSingle, entry, MUIV_List_Insert_Bottom);
  47. }
  48.  
  49. void InsertSorted (APTR entry)
  50. {
  51.     DoMethod (MUIM_List_InsertSingle, entry, MUIV_List_Insert_Sorted);
  52. }
  53.  
  54. void InsertActive (APTR entry)
  55. {
  56.     DoMethod (MUIM_List_InsertSingle, entry, MUIV_List_Insert_Active);
  57. }
  58.  
  59.